# -*- coding:utf-8 -*-
"""
input a list of words and remove those stop words and return
"""
import re

puncs = [u"　",u" ",u"'",u"\"",u"(",u")",u"（",u"）",u"-",u"，",u"。",u"…",u",",u".",u"\\",u"ㄧ",u"*"
        u"“",u"”",u"‘",u"’",u"」",u"「",u"、",u"/",u"：",u"？",u"《",u"》",
        u"★",u"● ",u"∶",u"＠",u"♀",u"♂"]
"""
tmplist = []
for w in puncs:
    print w,"\'"
    if puncs.count(w.decode('utf-8')) != 0:
        continue
    tmplist.append(w.decode('utf-8'))
puncs.extend(tmplist)
"""

lyric_stop_words = [
        # music related
        u"演唱",u"作词",u"作曲",u"编曲",u"制作",u"歌词",u"歌",u"曲",u"专辑",u"词",u"编辑",
        u""
        #other words
        u"了",u"有",u"合",u"女",u"我给",u"上",u"我一",u"玲",u"含",u"的",u"用",u"四",u"小时",u"油",u"二",u"下起",
        u"刷",u"蓝蓝",u"纸",u"个",u"男",u"口",u"令我",u"栋",u"吾",u"薛",u"卫",u"一次",u"打",u"是我",u"湘",
        u"可听",u"搁",u"發",u"牌",u"派",u"越",u"布",u"电",u"灯",u"登",u"在旁",u"又一",u"您不",u"模",u"展",u"部",
        u"道光",u"介绍",u"举",u"杂志",u"报",u"名",u"一双",u"走得",u"有说",u"内",u"博",u"院",u"社",u"致",
        u"到",u"星球",u"它的",u"甲",u"丞",u"角",u"水星",u"普",u"姆",u"数学",u"生在",u"翰",u"呒",u"正版",u"被扣",
        u"之夜",u"腿",u"制造",u"是",
        # place
        u"世界",u"北京"
        # pron
        u"你",u"我",u"你的",u"们",u""
        # not words
        u"而我",u"爱他",u"常德",u"上上",u"快把",u"多多",u"我把",u"到人",u"着脸",u"我不",u"了的",u"楼的",
        u"到下",u"點",u"你帮",u"我要",u"我有",u"已决",u""
        #number and quantity
        u"五",u"每一",u"级",u"周",u"三点",u"佰",u"一曲",u"一件",u"两",u"元",u"",
        # not simple chinese
        u"見",u"頭",u"記",u"這",u"說",u"麼",u"邊",u"實",u"對",u"樣",u"間",u"還",u"氣",u"變",
        u"個",u"單",u"開",u"尋",u"覺",u"鏡",u"場",u"許",u"熱",u"紅",u"轉",u"講",u"鐘",u"來",
        u"遠",u"誰",u"張",u"ぐ",u"臉",u"歡",u"終",u"學",u"線",u"長",u"陽",u"雙",u"語",u"簡",
        u"飛",u"à",u"從",u"結",u"現",u"電",u"讓",u"夢",u"",
        #name
        u"萱",u"韶",u"涵",u"张",u"巍",u"沈",u"玮",u"王",u"潘",u"莉",u"琪",u"尹",u"茹",
        u"泷",u"芸",u"俞",u"瑄",u"杜",u"袁",u"陈",u"蓉",u"薇",u"吉",
        ]

def removestop(words):
    """
    all words are in unicode format
    """
    tmpwords = []
    for word in words:
        if not check_word(word):
            continue
        tmpwords.append(word)
    return tmpwords

def check_word(word):
    if not checkpunctuation(word):
        return False
    if not checkdigit(word):
        return False
    if not checkEnChar(word):
        return False
    if lyric_stop_words.count(word) != 0:
        return False
    return True


def checkpunctuation(word):
    for punc in puncs:
        if word.count(punc) != 0:
            return False
    return True

def checkdigit(word):
    if re.search("\d",word):
        return False
    else:
        return True

def checkEnChar(word):
    if re.search("[A-Za-z]",word):
        return False
    else:
        return True
